import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';


import HomeDetail from './homeDetail';


export default class Home extends Component {
   _pressButton() {
        const { navigator } = this.props;
        //为什么这里可以取得 props.navigator?请看上文:
        //<Component {...route.params} navigator={navigator} />
        //这里传递了navigator作为props
        if(navigator) {
            navigator.push({
                name: '详情页面',
                component: HomeDetail,
            })
        }
    }

  render() {
    return (
      <View style={styles.container}>
        {this.renderNavbar}
      </View>
    );
  }
  renderNavbar(){
    <View>
        <Text style={styles.welcome} onPress={this._pressButton.bind(this)} >
            首页1
        </Text>
    </View>
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent:'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});